1. Field of the Invention
This invention is related to the field of processors, and more particularly, to performing data-speculative execution in a processor.
2. Description of the Related Art
Superscalar processors achieve high performance by executing multiple instructions concurrently and by using the shortest possible clock cycle consistent with their design. However, data and control flow dependencies between instructions may limit how many instructions may be issued at any given time. As a result, some processors support speculative execution in order to achieve additional performance gains.
One type of speculation is control flow speculation. Control flow speculation predicts the direction in which program control will proceed. For example, branch prediction may be used to predict whether a branch will be taken. Many types of branch prediction are available, ranging from methods that simply make the same prediction each time to those that maintain sophisticated histories of the previous branches in the program in order to make a history-based prediction. Branch prediction may be facilitated through hardware optimizations, compiler optimizations, or both. Based on the prediction provided by the branch prediction mechanism, instructions may be speculatively fetched and executed. When the branch instruction is finally evaluated, the branch prediction can be verified. If the prediction was incorrect, any instructions that were speculatively executed based on the incorrect predication may be quashed.
Another type of speculation that has been proposed is data speculation. For example, value prediction, which predicts the value of data items, may involve observing patterns in data and basing the prediction on those patterns (e.g., an index counter variable's value may be predicted by observing how prior values of that variable are incremented or decremented). Address prediction involves predicting the location of data. Yet another type of data speculation is called memory system optimism. In multi-processor systems, memory system optimism occurs when a processor speculatively executes an instruction using data from that processor's local cache before coherency checking is complete. Similarly, another type of data speculation may allow a load to speculatively execute before a store that has an uncomputed address at the time the load executes, even though the store may store data to the same address that the load accesses. In all of these types of data speculation, the underlying conditions are eventually evaluated, allowing the speculation to be verified or undone. If the speculation ends up being incorrect, the instructions that executed using the speculative data may be re-executed (e.g., with updated and/or non-speculative data).
Since speculation allows execution to proceed without waiting for dependency checking to complete, significant performance gains may be achieved if the performance gained from correct speculations exceeds the performance lost to incorrect speculations. Accordingly, it is desirable to be able to perform data speculation in a processor and to provide an efficient recovery mechanism for misspeculations.